/*     */ package com.controller.back;
/*     */ 
/*     */ import base.dao.BaseExample;
/*     */ import base.dao.BaseExample.Criteria;
/*     */ import base.utils.PagingResult;
/*     */ import com.model.Admin;
/*     */ import com.model.Users;
/*     */ import com.service.AbstractService;
/*     */ import com.service.PosterService;
/*     */ import com.service.UserService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"adminPoster"})
/*     */ public class AdminPosterController
/*     */ {
/*     */   @Autowired
/*     */   private PosterService posterService;
/*     */   @Autowired
/*     */   private UserService userService;
/*     */   @Autowired
/*     */   private AbstractService abstractService;
/*     */   
/*     */   @RequestMapping({"show"})
/*     */   public ModelAndView show(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  50 */     String id = request.getParameter("user_id");
/*     */     
/*  52 */     HttpSession session = request.getSession();
/*  53 */     ModelAndView mv = new ModelAndView();
/*  54 */     Admin t = (Admin)session.getAttribute("admin_user");
/*  55 */     if (t == null) {
/*  56 */       mv.setViewName("redirect:/manage/managelogin.do");
/*  57 */       return mv;
/*     */     }
/*  59 */     Users obj = (Users)this.userService.selectByPrimaryKey(id);
/*  60 */     BaseExample ba = new BaseExample();
/*  61 */     ba.or().andEqualTo("poster_user", id);
/*  62 */     ba.leftJoinOn("Accessory", "Accessory_id", "poster_accid").or(0).andEqualTo("Accessory", "DeleteFlag", "0");
/*  63 */     ba.or(0).andEqualTo("deleteFlag", "0");
/*  64 */     ba.setOrderByClause("Accessory.addTime DESC");
/*  65 */     List<Map<?, ?>> l = this.posterService.selectByExample(ba);
/*     */     
/*     */ 
/*  68 */     BaseExample ba1 = new BaseExample();
/*  69 */     ba1.or().andEqualTo("abstract_user", id);
/*  70 */     ba1.leftJoinOn("Accessory", "Accessory_id", "abstract_accid").or(0).andEqualTo("Accessory", "DeleteFlag", "0");
/*  71 */     ba1.or(0).andEqualTo("deleteFlag", "0");
/*  72 */     ba1.setOrderByClause("Accessory.addTime DESC");
/*  73 */     List<Map<?, ?>> l1 = this.abstractService.selectByExample(ba1);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  78 */     List<Map<?, ?>> l2 = new ArrayList();
/*     */     
/*  80 */     mv.addObject("poster", l);
/*  81 */     mv.addObject("list", l1);
/*  82 */     mv.addObject("obj", obj);
/*  83 */     mv.addObject("url", "/back/users/show.jsp");
/*  84 */     mv.setViewName("/index.jsp");
/*  85 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"index"})
/*     */   public ModelAndView getPosterList(HttpServletRequest request)
/*     */   {
/*  94 */     ModelAndView mv = new ModelAndView();
/*     */     
/*     */ 
/*  97 */     String page = (request.getParameter("page") == null) || 
/*  98 */       ("".equals(request.getParameter("page"))) ? "1" : request
/*  99 */       .getParameter("page");
/* 100 */     String size = (request.getParameter("size") == null) || 
/* 101 */       ("".equals(request.getParameter("size"))) ? "20" : request
/* 102 */       .getParameter("size");
/*     */     
/* 104 */     HttpSession session = request.getSession();
/* 105 */     Admin t = (Admin)session.getAttribute("admin_user");
/* 106 */     if (t == null) {
/* 107 */       mv.setViewName("redirect:/manage/managelogin.do");
/* 108 */       return mv;
/*     */     }
/*     */     
/* 111 */     String[] clause = { "Poster.*", "Users.*", "Accessory.*" };
/* 112 */     String sql = " LEFT JOIN Users ON Users.user_id = Poster.poster_user  Left JOIN Accessory ON Accessory.Accessory_id =Poster.poster_accid  WHERE   Poster.deleteFlag=0 AND Users.deleteFlag=0 AND Accessory.DeleteFlag=0 GROUP  BY Accessory.id  order by Accessory_zt ,Accessory.addTime desc ";
/*     */     
/*     */ 
/*     */ 
/* 116 */     Object[] obj = new Object[0];
/* 117 */     PagingResult pr = this.posterService.selectBySqlPaging(clause, sql, obj, Integer.valueOf(Integer.parseInt(page)), Integer.valueOf(Integer.parseInt(size)));
/* 118 */     List<Map<?, ?>> list = pr.getResultList();
/* 119 */     int s = Integer.parseInt(page) - 1;
/* 120 */     int h = s * Integer.parseInt(size);
/* 121 */     mv.addObject("ss", Integer.valueOf(h));
/* 122 */     mv.addObject("list", list);
/* 123 */     mv.addObject("page", page);
/* 124 */     mv.addObject("size", size);
/* 125 */     mv.addObject("total", Integer.valueOf(pr.getTotalSize()));
/* 126 */     mv.addObject("url", "/back/poster/index.jsp");
/* 127 */     mv.setViewName("/index.jsp");
/* 128 */     return mv;
/*     */   }
/*     */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\back\AdminPosterController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */